package egs.strings;


class str{
public static void main(String[] args){


  char[] charArr = { 'J', 'A', 'V', 'A','r' };


String str2="Felight rocks !! and the students of Felight rocks too !!";

String str3="felight rocks !! and the students of felight rocks too !!";


System.out.println("1: "+new String("Felight").isEmpty());
System.out.println("2: "+new String("Felight").charAt(05));
System.out.println("3: "+new String("Felight").concat("Rocks"));
System.out.println("4: "+new String("Felight").equalsIgnoreCase("FELIGHT"));
System.out.println("5: "+new String("Felight").length());
System.out.println("6: "+new String("Felight").replace('F', 'V'));
System.out.println("7: "+new String("Felight").substring(2, 5));
System.out.println("8: "+new String("Felight").toLowerCase());
System.out.println("9: "+new String("Felight").toUpperCase());
System.out.println("10: "+new String("Felight").toString());
System.out.println("11: "+new String("Felight          ").trim());

// returns a hash code for this string. s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] 
System.out.println("12: "+new String("Felight").hashCode());

// returns true if and only if this string contains the specified sequence of char values.
System.out.println("13: "+new String("Felight").contains("Fe"));

// The result is true if and only if this String represents the same sequence of char values as the specified sequence.
System.out.println("14: "+new String("Felight").contentEquals("Fe"));

// returns a String that contains the characters of the character array
System.out.println("15: "+new String("Felight").copyValueOf(charArr));

// returns the index of occurrence of character s
System.out.println("16: "+new String("Felight").indexOf('e'));


// returns index of first character of the substring "tutorials" 
System.out.println("17: "+new String(str3).indexOf("rocks"));

// search starts from index 10 and if located it returns the index of the first character of the substring "sea"
System.out.println("18: "+new String(str3).indexOf("rocks", 05));

 /* matches characters from index 06 in str3 to characters from
    index 06 in str2 considering same case of the letters.*/
System.out.println("19: "+new String(str3).regionMatches(06, str2, 06, 9));

 // replace all 'F' characters with 'V' characters.
System.out.println("20: "+new String(str2).replace('F', 'V'));

 /* replaces each substring of this string that matches the given
    regular expression with the given replacement */
System.out.println("21: "+new String(str3).replaceAll("!!","**"));

int val1=345;
double val2=345.67;
System.out.println("23 : "+ Integer.toString(val1));
System.out.println("24 : "+ Double.toString(val2));

// appends the string argument to the string buffer
 StringBuffer buff = new StringBuffer("FELIGHT ROCKS !! ");
System.out.println("25 : "+buff.append(" :-) "));

// deleting character from index 4 to index 9
System.out.println("26 : "+buff.delete(4, 9));

 // insert string value at offset 2
System.out.println("27 : "+buff.insert(4,"GHT R"));

 // deleting character at index 2
System.out.println("28 : "+buff.deleteCharAt(2));

/*The java.lang.StringBuffer.reverse() method causes this character sequence 
to be replaced by the reverse of the sequence.
*/
System.out.println("29 : "+new StringBuffer("malyalam").reverse());

// returns the specified subsequence from index 2 to 9
System.out.println("30 : "+new String(str3).subSequence(2,9));

/*The java.lang.String.compareTo() method compares two strings lexicographically.
 The comparison is based on the Unicode value of each character in the strings. 
The character sequence represented by this String object is compared lexicographically 
to the character sequence represented by the argument string.
*/

System.out.println("31 : ");

String s1 = "Felight", s2 = "Rocks";

    int retval = s1.compareTo(s2);

    // prints the return value of the comparison

    if (retval < 0) {
       System.out.println("s1 is greater than s2");
    }
        
    else if (retval == 0) {
       System.out.println("s1 is equal to s2");
    }
        
    else {
       System.out.println("s1 is less than s2");
    }

}
}
